// run: $exec < input
#include <iostream>
#include <queue>

long long const maxn = 1100;
long long const maxk = 1100000;
long long const inf = (long long)(1) << 60;

long long a[maxn][maxn];
long long col[maxn], row[maxn];
long long fa[maxk], fb[maxk];
long long n, m, k, p;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> m >> k >> p;
	for (long long i = 1; i <= n; i++)
		for (long long j = 1; j <= m; j++) {
			std::cin >> a[i][j];
			row[i] += a[i][j];
			col[j] += a[i][j];
		}

	std::priority_queue<long long> a, b;
	for (long long i = 1; i <= n; i++) a.push(row[i]);
	for (long long i = 1; i <= m; i++) b.push(col[i]);

	for (long long i = 1; i <= k; i++) {
		long long t = a.top(); a.pop();
		fa[i] = fa[i - 1] + t;
		a.push(t - p * m);
		t = b.top(); b.pop();
		fb[i] = fb[i - 1] + t;
		b.push(t - p * n);
	}

	long long ans = -inf;
	for (long long i = 0; i <= k; i++)
		ans = std::max(ans, fa[i] + fb[k - i] - i * (k - i) * p);

	std::cout << ans << '\n';
}

